<template>
  <div class="app-container">
    <!-- 按钮 -->
    <el-card class="box-card" style="margin-top: 10px">
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="buttonMethod(1)"
            v-hasPermi="['educational:mode:add']"
            >新增
          </el-button>
        </el-col>

        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
      </el-row>
    </el-card>
    <!-- 列表 -->
    <el-card class="table-card" style="margin-top: 10px">
      <el-table :data="dataList" stripe border>
        <el-table-column label="显示序号" align="center" prop="snCode" />
        <el-table-column label="学校角色名称" align="center" prop="snCode" />
        <el-table-column label="创建时间" align="center" prop="merchantName" />
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="buttonMethod(1, scope.row)"
              v-hasPermi="['educational:mode:edit']"
              >修改
            </el-button>
            <el-button
              size="mini"
              type="text"
              @click="buttonMethod(5, scope.row)"
              v-hasPermi="['educational:mode:status']"
            >
              授权
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
    <!-- 添加、编辑 -->
    <el-dialog :title="title" :visible.sync="status" width="30%">
      <el-form label-width="120px" size="small" class="formBox">
        <el-row class="mb_10">
          <el-col :span="20">
            <el-form-item label="角色名称：" class="is-required">
              <el-input placeholder="请输入角色名称" v-model="queryForm.contactPhone">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="buttonMethod(2)">取 消</el-button>
        <el-button type="primary" @click="buttonMethod(3)">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name: "",
  dicts: ["campus_status"],
  data() {
    return {
      status: false,
      title: "",
      dataList: [{ name: "1" }],
      queryParams: {},
      queryForm: {},
      total: 1,
      showSearch: true,
    };
  },
  created() {},
  methods: {
    // 获取列表数据
    getList() {},
    /**
     * 按钮点击事件处理方法
     */
    buttonMethod(options, value) {
      //options 等于 1
      if (options == 1) {
        this.queryForm = {};
        this.title = "添加";
        this.status = true;
      }
      //options 等于 2 关闭弹窗
      else if (options == 2) {
        this.queryForm = {};
        this.title = "";
        this.status = false;
      }
      //options 等于 3 关闭弹窗
      else if (options == 3) {
        this.queryForm = {};
        this.title = "";
        this.status = false;
      }
      //删除该校区信息
      else if (options == 4) {
        this.$confirm("确定删除该年级信息吗？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        });
      }
      //关闭/启用该校区
      else if (options == 5) {
        this.$confirm("确定关闭/启用该年级吗？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        });
      }
    },
    /**
     * 处理查询请求
     *
     * 将查询参数中的页码重置为1，并调用getList方法获取列表数据
     */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /**
     * 重置查询表单并重新执行查询操作
     */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /**处理导出操作*/
    handleExport() {
      this.download(
        "agents/agents/export",
        {
          ...this.queryParams,
        },
        `学校校区管理.xlsx`
      );
    },
  },
};
</script>
